home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Mag HDD Backup
/
Amiga Mag HDD Backup.zip
/
Amiga Mag HDD Backup
/
Alexander.img.bin
/
Alexander.img
/
10.4 material
/
Article.txt
< prev
Wrap
Text File
|
1983-05-04
|
9KB
|
171 lines
Revitalizing the X-Specs 3D Stereoscopic Glasses
Randy Finch
Many years ago a very interesting, very powerful, yet very
inexpensive (about $100) piece of hardware became available for
the Amiga computer. It consisted of a small black box that
plugged into the second mouse port and had two small holes that
allowed two sets of dark space age-like glasses to be plugged in.
One set of glasses was included in the package. The glasses
attached to the human head via a headband (see Figure 1). This
made it very nice for eyeglass wearers like me because they fit
comfortably over eyeglasses. The dark glasses consisted of LCD
lenses that could be darkened and lightened very quickly via
software and looked like a low-tech version of the virtual
reality glasses that are in vogue today. By allowing the left
eye to see only a left-eye perspective of a scene and the right
to see only a right-eye perspective via fast image switching, an
illusion of 3D could be had from a single Amiga display. This
piece of hardware was distributed by Haitex Resources, Inc. and
was known as the X-Specs 3D Stereoscopic Glasses.
I first saw this amazing piece of hardware at the 1988
AmiExpo in Chicago. I sat down, placed the glasses over my head,
and proceeded to view three-dimensional molecules and play a
quick game of Space Spuds. Both of these programs were included
with the glasses along with some demonstration and utility
programs. It was a great bargain. Being a programmer, I was
also interested to hear that a shared library was being written
so that any programmer could easily tap into the power of the
X-Specs glasses. I purchased the glasses shortly after the show
and never regretted it.
Although quite a number of software producers began to
support the X-Specs glasses, they never seemed to gain the
popularity I thought they deserved. For some time the glasses
have been hard to find, but now I cannot find any dealer that
carries them or even knows of anyone who does. However, I would
guess that a reasonably priced set of used glasses can still be
found. (For your information, I am not selling mine.) To
illustrate just how little software has been written for the
glasses, I searched the Gold Fish CD-ROM, which contains the
first 1000 Fred Fish disks, for the word X-Specs and only turned
up two references: LanderGame and RaiderGame. These are 3D games
for the X-Specs glasses. Both are on Fish Disk 544.
Like the X-Specs glasses, it seems that the interest in 3D
technology has always been an up and down phenomenon. In the
early part of the century, the old wooden stereoscopes that
consisted of two lenses that allowed each eye to see only one of
two images on a black & white postcard became popular. Their
popularity faded only to be revived years later when the
ViewMaster became available. Although the ViewMaster is still
available, it does not seem to be as popular as it was when I was
a kid. Of course, 3D movies were the craze back in the 50's.
Now, 3D movies are rarely, if ever, made. I believe that it has
something to do with having to wear funny glasses or look through
some kind of binocular device. When 3D imaging becomes available
for direct viewing just as we currently view a movie or a TV or a
computer monitor, it may become popular and stay popular.
Perhaps a more advanced kind of holography will provide the
technology.
Programming the X-Specs 3D Glasses
As I was told at AmiExpo, a shared library was soon released
so that even I could write programs for the X-Specs glasses. At
the time, I was working on a 3D function plotting program that
was a perfect candidate for adding X-Specs support. The library
is named xspecs.library. Version 1.2 of this library consists of
36 functions. Although I program in C, the library can be used
by any language that supports the standard Amiga shared
libraries. Table 1 shows the names and brief descriptions of the
functions available in the library. Several are available for
allocating and deallocating Rastport and Viewport data structures
for regular views, double-buffered views, and overscan views.
Pen colors, the pen number, and the drawing mode can all be set.
Lines, polygons, text, and even sprites can be drawn in three
dimensional space.
Unfortunately, the compressed files that I downloaded
containing the library did not have a C header file containing
the #pragma statements and function prototypes needed by my
program. However, the documentation had enough information in it
for me to create a file definition (.fd) file (Listing 1). I
used the fd2pragma program that was included with my SAS/C
compiler to convert this .fd file to a C header file containing
the #pragma statements. I then appended function prototypes.
This file is shown in Listing 2. With this completed, I was
ready to add X-Specs support to my program.
Listing 3 shows excerpts from my three dimensional function
plotting program. An earlier version of this program that does
not have X-Specs support can be found on Fish Disk 440. It is
named 3DPlot. The excerpts contain some code that I will not
discuss since it is not relevant to the current discussion. I
only left this code in the listing to provide a context for the
X-Specs function calls.
Notice first that the header file XSpecsLib.h is #included
near the beginning to make the #pragmas and function prototypes
available. Also, an external Library structure pointer (it is
opened in a different file) named XSpecsBase is declared.
When the user requests that an X-Specs plot be rendered, the
DrawGraph function is called with a global variable, plottype,
set equal to PLOTXSPECS, which is #defined in another header
file. A message port is declared along with an array containing
the 32 colors for the X-Specs screen. The RastPort and ViewPort
structures for the X-Specs display are allocated with the
XSpecsAllocView function. The NULL parameter indicates that a
32-color 320x200 screen should be created. Other screen
resolutions can be allocated by passing a different parameter.
The screen is displayed on the monitor with the XSpecsOn
function, which returns the message port of the display. The
MOUSEBUTTONS parameters indicates that only mouse button
messages should be sent to this port. Next, the palette is
filled by calling the XSpecsLoadRGB4 function.
Following the code further down, you will find a lot of
calculations being made to set up for the actual plot.
Eventually, another program function, CalcAndPlot3, is called.
This function is shown near the beginning of Listing 3. It does
the grunt work of calculating the three dimensional coordinates
for the plot on the X-Specs display. The plot consists of a
patchwork of four-sided polygons. After calculating the
coordinates of the four corners of a polygon and calculating the
color to use for it, three xspecs.library functions are called to
accomplish the task. First, XSpecsSetAPen is called to set the
appropriate color, XSpecsMove is called to move the pen to the
appropriate starting point in three dimensional space, and
XSpecsDraw is called three times to draw three sides of the four-
sided polygon. The fourth side is drawn when an adjoining four-
sided polygon is drawn. This saves a bit of plot time because
the adjoining sides do not have to be drawn twice.
Near the end of the DrawGraph function is a WaitPort system
function call. This call waits for a message to be received at
win's message port before closing the X-Specs display. The
Window pointer named win points to a window created by the
3DPlot program. Why am I waiting for a message at this port
rather than the one for the X-Specs display? I don't know. It
turns out if you use the following statement,
WaitPort(uport);
where uport is the message port returned by the XSpecsOn
function, a message will be received properly for a press of the
right mouse button, but the program will essentially freeze when
the left mouse button is pressed. By using the statement,
WaitPort(win->UserPort);
where win->UserPort is the message port of another window in the
3DPlot program not related to the X-Specs display, the left mouse
button can be pressed without freezing the program. However, it
takes a right button press after the left button press to cause a
message to be received at win->UserPort. I have not yet
determined why this works this way. If anyone has any ideas,
please let me know.
Finally, the XSpecsOff function is called to close the X-
Specs display, and XSpecsFreeView is called to deallocate the
RastPort and ViewPort structures for the display.
In Closing
The X-Specs 3D glasses can be programmed easily using
xspecs.library. The latest version of this library of which I am
aware is 1.2. I have tried contacting Richard Horne, who was one
of the people responsible for creating the library, to no avail.
If anyone out there in reader-land knows of a later version,
please write me care of this magazine or send me Email at
RandyWrite@aol.com. Also, if you would like to have a copy of my
3DPlot program with X-Specs support along with the .fd and C
header files discussed in this article, please let me know. I'll
get a disk out to you. If anyone has written X-Specs
applications and is willing to share them, please send me a disk.
I would be interested in seeing them. In the mean time, all you
Amiga programmers should pull out that compiler and get to work.